package com.pocket.insight.entity;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 描述：
 *
 * @author shuize
 * @create 2024/12/10
 */
public class AppParam {


    @Data
    public static class ValueMap {
        private Long                appId;
        private Map<String, Object> appParamNameValueMap = new HashMap();
        private Map<Long, Object>   appParamIdValueMap   = new HashMap();
        private boolean             hasBeenInitialized;

        public ValueMap(Long appId) {
            this.appId = appId;
        }

        public ValueMap(Long appId, Map<String, Object> appParamNameValueMap, Map<Long, Object> appParamIdValueMap) {
            this.appId = appId;
            if (appParamNameValueMap != null) {
                this.appParamNameValueMap = appParamNameValueMap;
            }
            if (appParamIdValueMap != null) {
                this.appParamIdValueMap = appParamIdValueMap;
            }
        }
        public void setAppParamNameValueMap(Map<String, Object> appParamNameValueMap) {
            if (appParamNameValueMap != null) {
                this.appParamNameValueMap = appParamNameValueMap;
            }

        }
        public void setAppParamIdValueMap(Map<Long, Object> appParamIdValueMap) {
            if (appParamIdValueMap != null) {
                this.appParamIdValueMap = appParamIdValueMap;
            }

        }
        public Object getSpecificAppParamValue(String paramName) {
            Long paramId = null;
            try {
                paramId = Long.valueOf(paramName);
            } catch (NumberFormatException var4) {
            }
            return this.appParamNameValueMap.get(paramName) != null ? this.appParamNameValueMap.get(paramName) : this.appParamIdValueMap.get(paramId);
        }

        public ValueMap copy() {
            return new ValueMap(this.appId, this.appParamNameValueMap == null ? new HashMap() : new HashMap(this.appParamNameValueMap), this.appParamIdValueMap == null ? new HashMap() : new HashMap(this.appParamIdValueMap));
        }
    }

    @Data
    public static class Options extends ParamAttrOptions implements Serializable {
        private Long datasetId;
        private String valueField;
        private String displayField;
        private String initialSelect;
        private Object sort;
    }
}
